import fetch from "../assets/js/fetch"
export default {
  state:{
    products:[]
  },
  mutations:{
      setProducts(state,data){
          state.products=data
          // console.log("test setAccounts")
          // console.log(state.accounts)
      }
  },
  actions: {
      //获取商品列表
      async getProducts({commit},stark){
        let data=await fetch.get("/api/products?name="+
          stark.name +
          "&type_id=" +
          stark.type_id +
          "&offset=&limit=99999"
        );
        commit("setProducts",data.data.products)
      },
      //添加用户
      async postProduct({commit},stark){
        await fetch.post("/api/products",stark)
      },
      //编辑用户信息
      async edit_product({commit},stark){
        await fetch.put("/api/products/"+stark.productsId,stark.products_form)
      },
      // //删除用户信息
      // async deleteProduct({commit},stark){
      //     await fetch.delete("/api/products/"+stark.productsId)
      // }
  }
}